// 解决科学计数
export function number2string(num) {
  num = String(num)
  var eSplit = num.split('e')
  var e = +(eSplit[1] || 0)
  var pad = '0'.repeat(500)
  var numSplit = eSplit[0].split('.')
  var str
  var numSplit1 = numSplit[1] || ''
  if (e < 0) {
    str = ('0.' + (pad + numSplit[0]).slice(e) + numSplit1)
  } else {
    str = (numSplit[0] + (numSplit1 + pad).slice(0, e) + '.' + numSplit1.slice(e))
  }
  return str.replace(/\.?0*$/, '').replace(/^0*/, '').replace(/^\./, '0.') || '0'
}

// 获取地址栏参数，key:参数名称
export function getUrlParams(key) {
  let reg = new RegExp('(^|&)' + key + '=([^&]*)(&|$)')
  let r = window.location.search.substr(1)
    .match(reg)
  if (r != null)
    return unescape(r[2])
  return null
}